package com.njbdqn.ALi.zjg.Controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.njbdqn.ALi.zjg.services.TotalCommentService;
import com.xubao.ali.services.PrintWriterService;

/**
 * Servlet implementation class TotalCommentController
 */
public class TotalCommentController extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private PrintWriterService out = new PrintWriterService();
	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String book_id = request.getParameter("book_id");
		
		int bid = Integer.parseInt(book_id);
		
		TotalCommentService tc = new TotalCommentService();
		
		PrintWriter ot = response.getWriter();
//		ot.write("{\"totalCommentAmount\":"+tc.findAll(bid)+"}");
		out.send(response, tc.findAll(bid));
		ot.flush();
		ot.close();
	}

}
